#include<iostream>
#include <ctime>
#include <windows.h>
#include <conio.h>
#include "maze.h"
using namespace std;
void menu();

void choice_menu(){
	char select;
	cout << "是否还继续游戏 是(任意键) 否(N)" << endl;
	select = getche();
	if(select == 110 ){
		menu();
	}
	else {
		cout << "下一关加载中....." << endl;
		Sleep(1000); 
	}
}

void menu(){
	int total;
	Map map1(11,11);
	map1.Born_Map();
	Map map2(13,13);
	map2.Born_Map();
	Map map3(15,15);
	map3.Born_Map();
	while(1){
		system("cls");
		cout << "\t\t\t           迷宫游戏                " << endl; 
		cout << "\t\t\t-----------------------------------" << endl;
		cout << "\t\t\t          1.开始游戏               " << endl;
		cout << "\t\t\t          2.编辑迷宫               " << endl; 
		cout << "\t\t\t          3.查看答案               " << endl;
		cout << "\t\t\t          4.退出游戏               " << endl; 
		cout << "\t\t\t-----------------------------------" << endl;
		char choice;
		cin >> choice;
		if(choice == '1'){
			system("cls");
			cout << "\t\t\t       游戏说明               " << endl;
			cout << "\t使用键盘的↑↓←→操纵老鼠，在规定时间内到达粮仓，即可成功" << endl;
			cout << "\t总共3关，闯关失败就会自动退出程序" << endl;
			system("pause");
			//第一关开始 
			system("cls"); 
			cout << "第一关加载中......" << endl;
			Sleep(1000); 
			system("cls");
			map1.Move_Time();
			system("pause");
			map1.Clean_visit();
			choice_menu();
			//第二关开始 
			system("cls");
			map2.Move_Time();
			system("pause");
			choice_menu();
			map2.Clean_visit();
			//第三关开始 
			system("cls");
			map3.Move_Time();
			cout << endl << "\t恭喜你闯关成功！！！" << endl;
			total = map1.Get_count() + map2.Get_count() + map3.Get_count();
			cout << "\t三关总得分为：" << total << endl; 
			map3.Clean_visit();
			system("pause");
	}
	else if(choice == '2'){
		cout << "请选择关卡(1-3)" << endl; 
		int choice;
		cin >> choice;
		if(choice == 1){
			map1.Show_Editor_Map();
			map1.Editor_Map();
		}
		else if(choice == 2){
			map2.Show_Editor_Map();
			map2.Editor_Map();
		}
		else if(choice == 3){
			map3.Show_Editor_Map();
			map3.Editor_Map();
		}
		system("pause");
	}
	else if(choice == '3'){
		cout << "请选择关卡(1-3)" << endl; 
		int choice;
		cin >> choice;
		if(choice == 1){
            map.Clean_visit();
			map1.Show_Editor_Map();
			map1.Search_path(11/2,11/2);
			map1.Show_short();
			map1.Clean_visit(); 
		}
		else if(choice == 2){
			map2.Clean_visit();
			map2.Show_Editor_Map();
			map2.Search_path(13/2,13/2);
			map2.Show_short();
			map2.Clean_visit();
		}
		else if(choice == 3){
			map3.Clean_visit();
			map3.Show_Editor_Map();
			map3.Search_path(15/2,15/2);
			map3.Show_short();
			map3.Clean_visit();
		}
		
		system("pause");
	}
	else if(choice == '4'){
		break;
	}
	}
	
} 

